#CPU=ARM
CPU=ARM
ifeq ($(CPU),ARM)
CC = aarch64-linux-gnu-gcc
CPP = aarch64-linux-gnu-g++
AR = aarch64-linux-gnu-ar
else
CC=gcc
CPP=g++
endif

CFLAGS += $(INCS) -g -D_LINUX -Wall -Wundef -funsigned-char -Wno-pointer-sign -Wstrict-prototypes -Wno-trigraphs \
		   -fno-strict-aliasing  -Werror -fshort-wchar \
		   -Werror-implicit-function-declaration \
		   -Werror=return-type  \

BIN = McRotShouKa.bin

#CFLAGS = -g   
#CPPFLAGS = -g  

SRCDIRS	= ./src  

INCS = -I ./include
     
LIB_PATH = -L ./
             
LIBS += -lpthread    


LDFLAGS += -lrt -Wl,-rpath=.
 
CSRCS = $(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.c))
CPPSRCS =  $(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.cpp))

#
#所有的.o文件列表
COBJS := $(CSRCS:.c=.o)
CPPOBJS := $(CPPSRCS:.cpp=.o)

# $@  --目标文件，
# $^  --所有的依赖文件，
# $<  --第一个依赖文件。


all:$(BIN)

$(COBJS) : %.o: %.c
	$(CC)  -o $@  -c $< $(INCS)  $(CFLAGS)
$(CPPOBJS) : %.o: %.cpp
	$(CPP) -o $@  -c $< $(INCS) $(CPPFLAGS)

$(BIN) : $(COBJS) $(CPPOBJS)
	$(CC) -o $(BIN) $^ $(LIB_PATH) $(LIBS)
	#scp $(BIN) root@10.2.102.206:/root
clean:			
	-rm $(BIN) $(COBJS) $(CPPOBJS)
#rm *.d
cleanall:
	-rm $(BIN) $(COBJS) $(CPPOBJS)
